/*******************************************************************************
* Copyright (c) 2010, 2018 西安秦晔信息科技有限公司
* Licensed under the Apache License, Version 2.0 (the "License");
*    you may not use this file except in compliance with the License.
*    You may obtain a copy of the License at
*
*       http://www.apache.org/licenses/LICENSE-2.0
*
*    Unless required by applicable law or agreed to in writing, software
*    distributed under the License is distributed on an "AS IS" BASIS,
*    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*    See the License for the specific language governing permissions and
*    limitations under the License.
*******************************************************************************/
package com.qinyeit.serviceapp.service.dishes.impl;

import com.qinyeit.serviceapp.exception.BusinessRunTimeException;
import com.qinyeit.serviceapp.utils.LocalUtils;
import com.qinyetech.springstage.core.date.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.qinyetech.springstage.core.service.BaseService;
import com.qinyeit.serviceapp.entity.DishesUnit;
import com.qinyeit.serviceapp.repository.dishes.DishesUnitRepository;
import com.qinyeit.serviceapp.service.dishes.DishesUnitService;

/** 
 * ClassName: DishesUnitServiceImpl <br/> 
 * Function: 菜品单位 业务实现 <br/> 
 * date: 2018-11-23 11:04:57 <br/> 
 * 
 * @author liuwenjin
 * @version 1.0
 * @since JDK 1.8
 */
@Service
@Transactional
public class DishesUnitServiceImpl extends BaseService<DishesUnit, Long> implements DishesUnitService {


	@Autowired
	private DishesUnitRepository dishesUnitRepository;


	@Override
	public void createDefault(Long dishesStoreId, Long merchantGroupId) {
		String[] units = {
				"斤","袋","克","箱","板",
				"盒","串","瓶","毫升","升",
				"碗","双","件","条","个",
				"盘","张","桶","根","包",
				"捆","听","付","卷","套",
				"支","块","提","对","片",
				"份"
		};
		for (int i = 0; i < units.length; i++) {
			DishesUnit unit = new DishesUnit();
			unit.setName(units[i]);
			unit.setStoreId(dishesStoreId);
			unit.setMerchantGroupId(merchantGroupId);
			unit.setUuid(LocalUtils.getUUID());
			unit.setUpdateTimestamp(DateUtils.current());
			this.save(unit);
		}

	}
}


